package com.holly.unit.bpmn.designer.core.strategy;

import com.holly.unit.bpmn.designer.constants.BpmnDesignerConstants;
import com.holly.unit.bpmn.designer.core.bpmn.BpmnModelFactory;
import com.holly.unit.bpmn.designer.enums.ApprovalModeEnum;
import com.holly.unit.bpmn.designer.model.ChildNode;
import org.activiti.bpmn.model.UserTask;

/**
 * 类描述: 发起人自己审批任务
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/13 9:18
 */
public class CreateSelfTaskStrategy implements CreateTaskStrategy{

    @Override
    public UserTask createTask(ChildNode node, BpmnModelFactory factory) {
        UserTask userTask = null;
        String id = node.getNodeId();
        String name = node.getProperties().getTitle();
        String assign = BpmnDesignerConstants.APPLY;
        // 会签任务
        if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.COUNTER_SIGN.fieldName())) {
            userTask = factory.createCountersignAssigneeTask(id,name,
                    BpmnDesignerConstants.COUNTER_SIGN_ASSIGNEE_NAME,
                    BpmnDesignerConstants.COUNTER_SIGN_COMPLTE_CONDITION,
                    assign);
        } else if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.OR_SIGN.fieldName())) {//或签任务
            userTask = factory.createAssigneeUserTask(id,name,assign);
        } else if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.NEXT_SIGN.fieldName())) {//顺序签
            // TODO 顺序签
        }
        return userTask;



    }
}
